package top.mcwebsite.playandroid.lib.markdown.utils

fun numberToLetters(number: Int): String {
    if (number <= 0) {
        return ""
    }

    val base = 'a'.code - 1
    val digit = number % 26
    val remaining = number / 26

    val currentChar = if (digit == 0) 'z' else (base + digit).toChar()

    return numberToLetters(remaining) + currentChar
}

fun intToRoman(number: Int): String {
    val values = intArrayOf(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
    val symbols = arrayOf("m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i")

    var remaining = number
    var result = ""

    for (i in values.indices) {
        while (remaining >= values[i]) {
            result += symbols[i]
            remaining -= values[i]
        }
    }

    return result
}
